package cn.hackcloud.mq;

import java.util.List;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
import org.apache.rocketmq.common.message.MessageExt;

public class Consumer {
	public static void main(String[] args) throws Exception {
		DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("hackcloud");
		consumer.setNamesrvAddr("47.93.251.127:9876");
		consumer.setVipChannelEnabled(false);
		consumer.subscribe("topicTest", "*");
		consumer.registerMessageListener(new MessageListenerOrderly() {

			@Override
			public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
				System.out.println(new String(msgs.get(0).getBody()));
				return ConsumeOrderlyStatus.SUCCESS;
			}
		});
		consumer.start();
	}

}
